import React, { PropTypes } from 'react';
import { connect } from 'dva';
import { routerRedux } from 'dva/router';
import { Menu, Breadcrumb, Icon, Collapse, Tabs} from 'antd';
const Panel = Collapse.Panel;
const TabPane = Tabs.TabPane;

import CourseList from './course/CourseList';
import CourseSearch from './course/CourseSearch';

function Course({location, dispatch, course }){
    const {dataSource, loading, total, current, modalVisible, modalType} = course;
    const usersearch = {
        onSearch(obj){
          dispatch(routerRedux({
              pathname:'/user',
              query:{page:1}
          }))
        }
    }
    const userlist = {
      dataSource,
      loading,
      total,
      current,
      onPageChange(page){
        dispatch(routerRedux.push({
          pathname: '/user',
          query: {page},
        }));
      }
    }
    return (
        <div className="normal">
          <CourseSearch {...usersearch}/>
          <CourseList {...userlist}/>
        </div>
    )
}

function mapStateToProps({ course }) {
  return { course };
}

export default connect(mapStateToProps)(Course);
